package com.sky.module.system.loginlog.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sky.module.system.loginlog.domain.entity.LoginLog;
import com.sky.module.system.loginlog.domain.form.LoginLogFormQuery;
import com.sky.module.system.loginlog.service.LoginLogService;
import com.sky.utils.Result;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author
 * @date 2023/3/8 20:46
 **/
@RestController
@RequestMapping("/api/loginlog")
public class LoginLogController {

    @Autowired
    private LoginLogService loginLogService;

    @PostMapping("query")
    public Result queryPage(@RequestBody LoginLogFormQuery loginLogFormQuery) {

        Page<LoginLog> page = loginLogService.queryPage(loginLogFormQuery);
        return Result.ok(page);
    }

    /***
     * @description TODO
     * @param id
     * @return com.sky.utils.Result
     * @date 2023/3/11 13:14
     *
     */
    @Delete("delete/{id}")
    public Result deleteByid(@PathVariable Integer id) {
        boolean flag = loginLogService.deleteById(id);
        if (flag) {
            return Result.ok();
        }
        return Result.error();
    }
}
